/**
 * 
 */
package com.base.myproject.client.ui;

import java.util.List;

import com.base.myproject.client.busi.BaseStore;
import com.base.myproject.client.busi.BO.BusiObject;
import com.base.myproject.client.jdbc.StoreInfo;
import com.extjs.gxt.ui.client.Style.Scroll;
import com.extjs.gxt.ui.client.Style.SelectionMode;
import com.extjs.gxt.ui.client.data.ModelType;
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
import com.extjs.gxt.ui.client.widget.grid.GridSelectionModel;

/**
 * @author zgw
 *2009-9-28 下午12:29:03
 * javazgw@gmail.com
 */
public class BaseChileGridPanel extends BaseChilePanel 
	
{
	boolean contentmenu=true;
	boolean contentkeynav=true;
	public BaseGrid<BusiObject> grid;
	public BaseChileGridPanel(ModelType type, StoreInfo storeinfo, List<ColumnConfig> columns,int mode)
	{
		this( type,  storeinfo,  columns, mode,true,true);
	}
	
	public BaseChileGridPanel(ModelType type, StoreInfo storeinfo, List<ColumnConfig> columns,int mode,boolean contentmenu,boolean contentkeynav)
	{

		setType(type);
		setStoreinfo(storeinfo);
		setColumns(columns);
		this.setVisible(false);
		this.contentkeynav = contentkeynav;
		this.contentmenu = contentmenu;
//		super( type,  storeinfo,  columns, mode);
		setActive();
		
	}
	public boolean isContentmenu() {
		return contentmenu;
	}

	public void setContentmenu(boolean contentmenu) {
		this.contentmenu = contentmenu;
	}

	public boolean isContentkeynav() {
		return contentkeynav;
	}

	public void setContentkeynav(boolean contentkeynav) {
		this.contentkeynav = contentkeynav;
	}

	public void setActive()
	{
		
		if(!isactive)
		{
		setIsactive(true);
			//装载
		store= new BaseStore<BusiObject>(type, storeinfo);
		ColumnModel cm = new ColumnModel(columns);
		grid = new BaseGrid<BusiObject>(store, cm,contentmenu,contentkeynav);
		grid.setAutoHeight(true);
		grid.setAutoWidth(true);
		GridSelectionModel<BusiObject> sm = new GridSelectionModel<BusiObject>();
		sm.setSelectionMode(SelectionMode.SINGLE);
		grid.setSelectionModel(sm);
		//子表不主动读取记录，2010-2-7 屏蔽
		//store.load();
		this.add(grid);
		this.setScrollMode(Scroll.AUTO);
/*		this.setHeight("100");
		this.setWidth("900");*/
		//this.setAutoHeight(true);
		//this.setAutoWidth(true);
//		grid.setWidth("200");
//		grid.setHeight("100");
		//grid.getView().setForceFit(true);
		this.layout();
		}
		//if(!isVisible())
		{
			this.setVisible(true);
		}
	}
	
}
